<script type="text/javascript" src="js/jquery/jquery.js"></script>
<script type="text/javascript" src="js/jquery/jquery.meio.mask.js" charset="utf-8" ></script>
<script type="text/javascript" src="js/jquery/jquery.validate.js" charset="utf-8" ></script>
<script type="text/javascript" src="js/form/validations.js" charset="utf-8" ></script>
<script type="text/javascript" src="js/ajaxupload.3.5.js" ></script>
{literal}
<script>
	$(function(){
		var btnUpload=$('#upload');
		var btnUpload2=$('#upload2');
		var status=$('#status');
		var status2=$('#status2');
		new AjaxUpload(btnUpload, {
			action: 'upload-file.php',
			name: 'uploadfile',
			data: {action: 'add',type: 'logo',size: '250',id: $('#id').val()},
			cache: 'false',
			onSubmit: function(file, ext){
				 if (! (ext && /^(jpg|png)$/.test(ext))){ 
					// extension is not allowed 
					status.text('Only JPG, PNG or GIF files are allowed');
					return false;
				}
				status.text('Uploading...');
			},
			onComplete: function(file, response){
				//On completion clear the status
				status.text('');
				//Add uploaded file to list
				$('#foto').attr('src','images/nophoto.png');
				if(response!="error"){
					$('#foto').attr('src',response+'?'+ new Date().getTime());
					$('#logopath').val(response);
				} else{
					$('#files').html('<img class="fondoyborde" width="200px" src="images/nophoto.png" />').addClass('error');
				}
			}
		});
		new AjaxUpload(btnUpload2, {
			action: 'upload-file.php',
			name: 'uploadfile',
			data: {action: 'add',type: 'afiche',size: '600',id: $('#id').val()},
			cache: 'false',
			onSubmit: function(file, ext){
				 if (! (ext && /^(jpg|png)$/.test(ext))){ 
					// extension is not allowed 
					status2.text('Only JPG, PNG or GIF files are allowed');
					return false;
				}
				status2.text('Uploading...');
			},
			onComplete: function(file, response){
				//On completion clear the status
				status2.text('');
				//Add uploaded file to list
				$('#foto2').attr('src','images/nophoto.png');
				if(response!="error"){
					$('#foto2').attr('src',response+'?'+ new Date().getTime());
					$('#afichepath').val(response);
				} else{
					$('#files2').html('<img class="fondoyborde" width="200px" src="images/nophoto.png" />').addClass('error');
				}
			}
		});
	});
</script>
{/literal}

<link rel="stylesheet" type="text/css" media="screen" href="css/validations.css" /><div class="clear"></div>
<div class="grid_10">
	<div class="box round first fullpage">
   		<h2>Formulario de Datos</h2>  
       	<div class="block ">
           	<form id="formTransportes" method="post" action="comercios.php">
           		<input type="hidden" id="action" name="action" value="save"/> 
           		<input type="hidden" id="id" name="id" value="{$comercios.idTransporte}"/> 
           		<table class="form">
					<tr>
						<td width="90px"><label>Nombre:</label></td>
						<td><input type="text" id="nombre" name="nombre" value="{$comercios.nombre}" class="required" size="40"   /></td>
					</tr>
					<tr>
						<td><label>Categor&iacute;a:</label></td>
						<td>
							<select style="width: 200px" id="categoria" name="categoria">
								<option value=""></option>
								{foreach from=$categoriasList item="categoria"}
									<option {if $comercios.categoria == $categoria.id} selected="selected"{/if} value="{$categoria.id}">{$categoria.nombreCategoria}</option>
								{/foreach}
							</select>
						</td>
					</tr>
					<tr>
						<td><label>Provincia:</label></td>
						<td>
							<select style="width: 150px" id="idProvincia" name="idProvincia">
								<option value=""></option>
								{foreach from=$provincias item="provincia"}
									<option {if $comercios.idProvincia == $provincia.id} selected="selected"{/if} value="{$provincia.id}">{$provincia.provincia}</option>
								{/foreach}
							</select>
						</td>
					</tr>
					<tr>
						<td><label>Ciudad:</label></td>
						<td>
							<select style="width: 150px" id="idCiudad" name="idCiudad">
								<option value=""></option>
								{foreach from=$ciudades item="ciudad"}
									<option {if $comercios.idCiudad == $ciudad.idCiudad} selected="selected"{/if} value="{$ciudad.idCiudad}">{$ciudad.ciudad}</option>
								{/foreach}
							</select>
						</td>
					</tr>
					<tr>
						<td><label>Direcci&oacute;n:</label></td>
						<td><input type="text" id="direccion" name="direccion" value="{$comercios.direccion}"   size="30"  /></td>
					</tr>
					<tr>
						<td><label>Tel&eacute;fono:</label></td>
						<td><input type="text" id="telefono" name="telefono" value="{$comercios.telefono}"  /></td>
					</tr>
					<tr>
						<td><label>Email:</label></td>
						<td><input type="text" id="email" name="email" value="{$comercios.email}"  size="30"  /></td>
					</tr>
					<tr>
						<td><label>Web:</label></td>
						<td><input type="text" id="web" name="web" value="{$comercios.web}"  size="40" /></td>
					</tr>
					<tr>
						<td><label>Destacado:</label></td>
						<td>
							<select id="destacado" name="destacado">
								<option value="0" {if $comercios.destacado == 0}selected{/if} >No</option>
								<option value="1" {if $comercios.destacado == 1}selected{/if} >Si</option>
							</select>		
						</td>
					</tr>
					<tr>
						<td><label>Texto:</label></td>
						<td>
							<textarea id="texto" name="texto"  rows="4" cols="30">{$comercios.texto}</textarea>
						</td>
					</tr>
				</table>
				
				<table class="form">
					<tr>
						<td class="button" colspan="2"><br><br>
							<input type="submit" class="save btn btn-grey" value="Guardar cambios" />
							<input type="button" value="Cancelar" class="btn btn-grey" onclick="goToPage('comercios.php');" />
						</td>
					</tr>  		
				</table>
			</form>
		</div>
	</div>
</div>